/*
Copyright (C) 2009-2010 Xanadu Development Team

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; version 2
of the License.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
*/

#include "../PacketCreator.h"

PacketWriter* PacketCreator::addMessengerPlayer(string from, Player *player, int pos, int channel) {
    pw.writeShort(MESSENGER);
    pw.write(0x00);
    pw.write(pos);
    addCharLook(player, true);
    pw.writeString(from);
    pw.write(channel);
    pw.write(0x00);
    return &pw;
}

PacketWriter* PacketCreator::removeMessengerPlayer(int pos) {
    pw.writeShort(MESSENGER);
    pw.write(0x02);
    pw.write(pos);
    return &pw;
}

PacketWriter* PacketCreator::updateMessenger(string from, Player *player, int pos, int channel) {
    pw.writeShort(MESSENGER);
    pw.write(0x07);
    pw.write(pos);
    addCharLook(player, true);
    pw.writeString(from);
    pw.write(channel);
    pw.write(0x00);
    return &pw;
}

PacketWriter* PacketCreator::joinMessenger(int pos) {
    pw.writeShort(MESSENGER);
    pw.write(0x01);
    pw.write(pos);
    return &pw;
}

PacketWriter* PacketCreator::messengerChat(string text) {
    pw.writeShort(MESSENGER);
    pw.write(0x06);
    pw.writeString(text);
    return &pw;
}

PacketWriter* PacketCreator::messengerNote(string text, int mode, int mode2) {
    pw.writeShort(MESSENGER);
    pw.write(mode);
    pw.writeString(text);
    pw.write(mode2);
    return &pw;
}

PacketWriter* PacketCreator::messengerInvite(string from, int messengerid) {
    pw.writeShort(MESSENGER);
    pw.write(0x03);
    pw.writeString(from);
    pw.write(0x00);
    pw.writeInt(messengerid);
    pw.write(0x00);
    return &pw;
}
